// miniprogram/page/API/pages/get-battery-info/get-battery-info.js
Page({
  data: {
    theme: 'light',
    schema:[],
    title:'电量',
    formData:{},
    result:''
  },

  getBatteryInfo() {
    wx.getBatteryInfo({
      complete: (res) => {
        const msg = res.isCharging ? '充电中' : '使用电池中'
        this.setData({
          level: res.level,
          isCharging: msg,
          result:res
        })
      },
    })
  },
  onLoad() {
    this.setData({
      theme: wx.getSystemInfoSync().theme || 'light'
    })

    if (wx.onThemeChange) {
      wx.onThemeChange(({theme}) => {
        this.setData({theme})
      })
    }
  }
})
